package org.lemon.transport.coap.server.service.resource;

import org.eclipse.californium.core.CoapResource;
import org.lemon.transport.coap.server.service.CoapService;
import org.lemon.transport.coap.server.service.CoapTransportContext;
import org.lemon.transport.coap.server.session.CoapDtlsSessionInfo;
import org.lemon.transport.context.service.TransportService;

import java.net.InetSocketAddress;
import java.util.concurrent.ConcurrentMap;

public abstract class AbstractCoapTransportResource extends CoapResource {

    protected final CoapTransportContext transportContext;

    protected final ConcurrentMap<InetSocketAddress, CoapDtlsSessionInfo> dtlsSessionsMap;

    public AbstractCoapTransportResource(String name, CoapTransportContext transportContext, CoapService coapService) {
        super(name);
        this.transportContext = transportContext;
        this.dtlsSessionsMap = coapService.getDtlsSessionsMap();
    }

    public TransportService getTransportService() {
        return transportContext.getTransportService();
    }
}
